/**
 * Created by Administrator on 2017/1/7.
 */
var should = require('should');
var Sample = require('../models/sample.js');

suite('sample-default-unit-tests', function () {
    var expectedChapters = [
        'AspNetDeveloperBaseSamples',
        'AspNetMvc5Samples',
        'BeginningCSharpSamples',
        'CleanCodeSamples',
        'ClrViaSamples',
        'cz241126',
        'DefinitiveGuideHtml5Samples',
        'Demo',
        'Docx-90944',
        'DocXSamples',
        'Doudizhus',
        'EssentialCSharpSamples',
        'EuropeanCastle',
        'ILSpySourceCode',
        'MahApps.Metro-master',
        'NanYanWeb',
        'NFine',
        'Others',
        'ProfessionalCSharpSamples',
        'UmlSamles',
        'WPF-UI-Framework-master',
        'WPFSamples',
        'WxPayAPI',
        '代理商平台'
    ];
    var sample = new Sample();
    var demo = '示例';
    var projects = 'D:\\Projects\\CSharp Projects';

    test('.properties', function () {
        should.equal(sample, demo);
        should.equal(sample.name, demo);
        should.equal(sample.toString(), demo);
        should.equal(sample.path, projects);
        should.equal(Sample.prototype.name, demo);
        should.equal(Sample.prototype.toString(), demo);
        should.equal(Sample.prototype.path, projects);
    });

    test('.chapters', function () {
        var chapters = sample.chapters;
        should.equal(chapters.length, 24, 'has 24 items');
        should.deepEqual(chapters, expectedChapters, 'all projects files');
    });

    test('.getChapters(callback)', function (done) {
        sample.getChapters(chaptersCallback);

        function chaptersCallback(err, chapters) {
            should.ifError(err);
            should.equal(chapters.length, 24,'has 24 items');
            done();
        }
    });

    test('.getChapters(excludes, callback)', function (done) {
        var excludes = ['Demo', 'Docx-90944'];
        expectedChapters.splice(7, 2);
        sample.getChapters(excludes, filterChaptersCallback);

        function filterChaptersCallback(err, chapters) {
            should.ifError(err);
            should.equal(chapters.length, 22,'has 22 items');
            should.deepEqual(chapters, expectedChapters, 'all projects files');
            done();
        }
    })
});

